"""
Server端
"""

import socket


def run_server():
    server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    server.bind(("0.0.0.0", 8090))
    server.listen()
    sock, addr = server.accept()

    # 获取从客户端发送的数据
    data = sock.recv(1024)

    if data:
        sock.send("hi {data}".format(data=data.decode("utf8")).encode("utf8"))

    print(data.decode("utf8"))

    server.close()
    sock.close()


if __name__ == '__main__':
    run_server()
